Namespace - LJCDBDataAccess
Returns
The result XML message.
Syntax
C# |
private DbResult Update()
|
Updates a database record.
(E)
Remarks
This method is called from the
Execute()
method if the DbRequest.QueryType is "Update".
(E)
Example
C# |
private static void Update(DbDataAccess dbDataAccess
, DbColumns dataDefinition)
{
List<string> columnNames = new List<string>();
foreach (DbColumn column in dataDefinition)
{
if (column.ColumnName != "Id")
{
columnNames.Add(column.ColumnName);
}
}
Person dataRecord = new Person()
{
Name = "TestNameUpdated"
};
var dataColumns = DbCommon.QueryDataColumns(dataRecord
, dataDefinition, columnNames);
var keyColumns = new DbColumns()
{
{ "Name}, (object)"TestName" }
};
dataDefinition.LJCSetExcludeKeyValue("PrincipleFlag");
var queryKeyColumns = DbCommon.QueryKeys(keyColumns, dataDefinition);
DbRequest dbRequest = new DbRequest()
{
Columns = dataColumns,
KeyColumns = queryKeyColumns
QueryType = QueryType.Update.ToString(),
TableName = "PersonTest",
};
DbResult dbResult = dbDataAccess.Execute(dbRequest);
if (dbResult != null)
{
string sqlStatement = dbResult.ExecutedSql;
int affectedCount = dbResult.AffectedRecords;
}
return retValue;
}
|